<template>
	<div>
		<el-form ref="form" :model="form" label-width="100px">

		<!-- 	<el-form-item label="序号" prop="nId">
				<el-input v-model="form.nId"></el-input>
			</el-form-item> -->


			<el-form-item label="护理级别" prop="nClass">
				<el-input v-model="form.nClass"></el-input>
			</el-form-item>

			<el-form-item label="状态" prop="status">
				<el-select v-model="form.status" placeholder="请选择状态" clearable :style="{width: '100%'}">
					<el-option v-for="(item, index) in statusData" :key="index" :label="item.label" :value="item.value"
						:disabled="item.disabled"></el-option>
				</el-select>
			</el-form-item>
			<el-form-item label="备注" prop="note">
				<el-input v-model="form.note"></el-input>
			</el-form-item>

			<el-form-item>
				<el-button type="primary" @click="save">保存</el-button>
			</el-form-item>
		</el-form>

	</div>
</template>

<script>
	export default {
		name: 'nurseClassEdit',
		components: {

		},
		props: [
			'showEdit',
			'nid',
			'editid'
		],
		data() {
			return {
				form: {
					nId: '',
					nClass: '',
					status: '',
					note: ''
				},
				statusData: [{
					"label": "启用",
					"value": "启用"
				}, {
					"label": "不启用",
					"value": "不启用"
				}],
				url: '/nurseClass/save',
				depts: [],
			}
		},
		created() {
			// this.init()
			console.log("this.editid:" + this.editid)
			if (this.editid) {

				this.axios.get('/nurseClass/toedit', response => {
					console.log(response);

					console.log(response.obj.nid);
					this.form.nId = response.obj.nid
					this.form.nClass = response.obj.nclass
					this.form.status = response.obj.status
					this.form.note = response.obj.note

				}, {
					nId: this.editid
				})
			}
		},
		methods: {
			save() {
				this.$refs['form'].validate((valid) => {
					if (valid) {
						this.axios.post(this.url, response => {
							// 子组件要改变父组件的值
							this.$emit('update:show', false)
							this.$emit('getData')
						}, this.form)
					}
				})
			}

		}
	}
</script>

<style>
</style>
